package com.bamanker.cloudapi.model.error;

import com.bamanker.cloudapi.constant.CommonErrorConstant;
import com.bamanker.cloudapi.model.response.ResultCode;

/**
 * @author bamanker
 */

public enum CommonErrorCode implements ResultCode {
    /**
     * 错误请求
     */
    INVALID_REQUEST(false, CommonErrorConstant.INVALID_REQUEST, "Invalid request, for reason: "),
    /**
     * 参数验证错误
     */
    INVALID_ARGUMENT(false, CommonErrorConstant.INVALID_ARGUMENT, "Validation failed for argument "),
    /**
     * 未找到资源
     */
    NOT_FOUND(false, CommonErrorConstant.NOT_FOUND, "Resource not found."),
    /**
     * 未知错误
     */
    UNKNOWN_ERROR(false, CommonErrorConstant.UNKNOWN_ERROR, "Unknown server internal error."),
    /**
     * 被限流
     */
    TOO_MANY_REQUEST(false,CommonErrorConstant.TOO_MANY_REQUESTS,"Too many requests,You have been rate-limited.");


    CommonErrorCode(Boolean success, String code, String message) {
        this.success = success;
        this.code = code;
        this.message = message;

    }

    /**
     * 响应是否成功
     */
    private Boolean success;
    /**
     * 响应状态码
     */
    private String code;
    /**
     * 响应信息
     */
    private String message;


    @Override
    public String getCode() {
        return code;
    }

    @Override
    public String getMessage() {
        return message;
    }

    @Override
    public boolean getSuccess() {
        return success;
    }

}
